<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"> 

<h:head></h:head> 
<body onload="#{hotelManagedBean.searchHotel(null,creaPacchettoManagedBean.pacchettoPreconfiguratoDTO.destinazione_pacchetto)};#{escursioneManagedBean.searchEscursione(null,creaPacchettoManagedBean.pacchettoPreconfiguratoDTO.destinazione_pacchetto)};#{creaPacchettoManagedBean.fillListeVoli(creaPacchettoManagedBean.pacchettoPreconfiguratoDTO.destinazione_pacchetto)}"> 
	<h:form>    
	    <p:menubar>  
	        <p:submenu label="Inserisci prodotti" icon="ui-icon-document">  
	            <p:menuitem value="Hotel" icon="ui-icon-contact" url="crea_hotel.xhtml?faces-redirect=true"/>  
	            <p:menuitem value="Escursioni" icon="ui-icon-contact" url="crea_escursione.xhtml?faces-redirect=true"/>
	            <p:menuitem value="Voli" icon="ui-icon-contact" url="crea_volo.xhtml?faces-redirect=true"/>  
	        </p:submenu>  
	  
	        <p:submenu label="Gestisci prodotti" icon="ui-icon-document">  
	            <p:menuitem value="Hotel" icon="ui-icon-contact" url="cerca_hotel.xhtml?faces-redirect=true"/>  
	            <p:menuitem value="Escursioni" icon="ui-icon-contact" url="cerca_escursioni.xhtml?faces-redirect=true"/>
	            <p:menuitem value="Voli" icon="ui-icon-contact" url="cerca_voli.xhtml?faces-redirect=true"/>  
	        </p:submenu>  
	  
	        <p:submenu label="Pacchetti Preconfigurati" icon="ui-icon-document">  
	            <p:menuitem value="Crea" url="crea_pp.xhtml?faces-redirect.xhtml"/>  
	            <p:menuitem value="Gestisci" url="gestione_pp.xhtml?faces-redirect=true" />  
	        </p:submenu>    
	  
	        <f:facet name="options">  
	            <p:commandButton value="Logout" icon="ui-icon-extlink" action="#{loginManagedBean.logout()}"/>  
	        </f:facet>  
	    </p:menubar>  
  	</h:form>  
  	<h:form>
  		<p:messages id="messaggio" showDetail="true" autoUpdate="true" closable="true" /> 
  	</h:form>
  	<p:dialog id="modalDialog" header="Modal Dialog" widgetVar="dlg2" modal="true" height="100">  
    <h:outputText value="Prodotto inserito correttamente" />  
</p:dialog> 
<h:form id="search_form">  
    <p:tabView id="tabView" dynamic="true" cache="true">  
        <p:tab id="hotel" title="Hotel">  
           <p:dataTable id="hotelOutput" var="n" value="#{hotelManagedBean.listaHotel}">
 					<p:column headerText="ID">
                   		<h:outputText value="#{n.id}"/>
               		</p:column>
					
					<p:column headerText="Nome">
	                    <h:outputText value="#{n.nome}"/>
	                </p:column>
	                
	                <p:column headerText="Citta">
	                    <h:outputText value="#{n.luogo}"/>
	                </p:column>
	
	                <p:column headerText="Prezzo">
	                    <h:outputText value="#{n.prezzo}"/>
	                </p:column>
	                <p:column>
       					<p:commandButton  value="Aggiungi Hotel" action="#{creaPacchettoManagedBean.addHotel(n)}" disabled="#{creaPacchettoManagedBean.hotelCheckInsert()}" rendered="#{!creaPacchettoManagedBean.isHotelInserted(n)}" />
       					<p:commandButton  value="Rimuovi Hotel" action="#{creaPacchettoManagedBean.rimuoviHotel(n)}" disabled="#{!creaPacchettoManagedBean.hotelCheckInsert()}" rendered="#{creaPacchettoManagedBean.isHotelInserted(n)}"/>
      				</p:column>
       		</p:dataTable>
        </p:tab>  
  
        <p:tab id="voli" title="Voli">  
            <h:panelGrid columns="2" cellpadding="10">
            	
            		<p:outputLabel value="Seleziona un volo di andata:"/>
                	<p:dataTable id="voliAndataOutput" var="n"  value="#{creaPacchettoManagedBean.listaVoliAndata}">  
            			<p:column headerText="ID">
                    		<h:outputText value="#{n.id}"/>
                		</p:column>

                		<p:column headerText="Citta Partenza">
                    		<h:outputText value="#{n.partenza}"/>
                		</p:column>

		                <p:column headerText="Citta Arrivo">
       			             <h:outputText value="#{n.destinazione}"/>
       			        </p:column>

                		<p:column headerText="Prezzo">
                    		<h:outputText value="#{n.prezzo}"/>
                		</p:column>
                		<p:column>
                    		<p:commandButton value="Aggiungi Volo" action="#{creaPacchettoManagedBean.addVolo(n)}" disabled="#{creaPacchettoManagedBean.voloAndataCheckInsert()}" rendered="#{!creaPacchettoManagedBean.isVoloInserted(n)}" />
                    		<p:commandButton value="Rimuovi Volo" action="#{creaPacchettoManagedBean.rimuoviVolo(n)}" disabled="#{!creaPacchettoManagedBean.voloAndataCheckInsert()}" rendered="#{creaPacchettoManagedBean.isVoloInserted(n)}" /> 
                		</p:column>
        			</p:dataTable> 
 				
 					<p:outputLabel value="Seleziona un volo di ritorno:"/>
	                <p:dataTable id="voliRitornoOutput" var="n"  value="#{creaPacchettoManagedBean.listaVoliRitorno}">  
	            		<p:column headerText="ID">
	                    		<h:outputText value="#{n.id}"/>
	                		</p:column>
	
	                		<p:column headerText="Citta Partenza">
	                    		<h:outputText value="#{n.partenza}"/>
	                		</p:column>
	
			                <p:column headerText="Citta Arrivo">
	       			             <h:outputText value="#{n.destinazione}"/>
	       			        </p:column>
	
	                		<p:column headerText="Prezzo">
	                    		<h:outputText value="#{n.prezzo}"/>
	                		</p:column>
	                		
	                		<p:column>
	                    		<p:commandButton value="Aggiungi Volo" action="#{creaPacchettoManagedBean.addVolo(n)}" disabled="#{creaPacchettoManagedBean.voloRitornoCheckInsert()}" rendered="#{!creaPacchettoManagedBean.isVoloInserted(n)}"/>
                    			<p:commandButton value="Rimuovi Volo" action="#{creaPacchettoManagedBean.rimuoviVolo(n)}" disabled="#{!creaPacchettoManagedBean.voloRitornoCheckInsert()}" rendered="#{creaPacchettoManagedBean.isVoloInserted(n)}"/>
	                		</p:column>
	        		</p:dataTable> 
        		
       		</h:panelGrid> 
        </p:tab>  
  
        <p:tab id="escursioni" title="Escursioni">  
           <p:dataTable id="escursioniOutput" var="n" value="#{escursioneManagedBean.listaEscursioni}">
  						<p:column headerText="ID">
                    		<h:outputText value="#{n.id}"/>
                		</p:column>
						
						<p:column headerText="Nome">
		                    <h:outputText value="#{n.nome}"/>
		                </p:column>
						
		                <p:column headerText="Citta">
		                    <h:outputText value="#{n.luogo_Fruizione}"/>
		                </p:column>
		
		                <p:column headerText="Prezzo">
		                    <h:outputText value="#{n.prezzo}"/>
		                </p:column>
		             
		                <p:column>
		                	<p:commandButton value="Aggiungi Escursione" action="#{creaPacchettoManagedBean.addEscursione(n)}" rendered="#{!creaPacchettoManagedBean.isEscursioneInserted(n)}"/>
		                	<p:commandButton value="Rimuovi Escursione" action="#{creaPacchettoManagedBean.rimuoviEscursione(n)}" rendered="#{creaPacchettoManagedBean.isEscursioneInserted(n)}"/>
		                </p:column>
                </p:dataTable>	
        </p:tab>  
        <p:tab id="descrizione" title="Descrizione">  
            <p:inputTextarea autoResize="true" title="Descrizione" value="#{creaPacchettoManagedBean.pacchettoPreconfiguratoDTO.descrizione}" style="width:400px; height:400px"/>
        </p:tab>  
   </p:tabView>
   <h:commandButton  value="Crea Pacchetto" action="#{creaPacchettoManagedBean.creaPacchetto()}"/>  
</h:form>  
</body> 
</html>
